package com.delio.server.produccion.codigocolores;

import java.util.List;

import com.delio.client.produccion.codigocolores.CodigoColor;
import com.delio.client.produccion.codigocolores.CodigoColorService;
import com.delio.server.base.Conexion;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.ibatis.sqlmap.client.SqlMapClient;

public class CodigoColorServiceImpl extends RemoteServiceServlet
implements CodigoColorService{
	private static final long serialVersionUID = 1L;
	
    static SqlMapClient sqlMap = Conexion.getSqlMap();

	@Override
	public boolean guardar(CodigoColor cc) {
		   boolean var = false;
		   try{
			   sqlMap.insert("insertCodigoColor",cc);
			   var = true;
		   }catch(Exception e){
			   e.printStackTrace();
		   }
			return var;
	}

	@Override
	public boolean eliminar(Integer id) {
		boolean var = false;
		try{
			sqlMap.delete("deleteCodigoColor",id);
			var = true;
		}catch(Exception e){
			e.printStackTrace();
		}
		return var;
	}

	@Override
	public boolean actualizar(CodigoColor cc) {
		boolean var = false;
		
		try{
		   sqlMap.update("updateCodigoColor",cc);
		   var = true;	
		}catch(Exception e){
			e.printStackTrace();
		}
		return var;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CodigoColor> ListarCodigoColores(Integer id) {
		List<CodigoColor> ledp = null;
		try{
			ledp = sqlMap.queryForList("ListCodigoColores",id);
		}catch(Exception e){
			e.printStackTrace();
		}
		return ledp;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CodigoColor> ListarCodigoColores() {
		List<CodigoColor> ledp = null;
		System.out.println("entro en listarCodigoColor");
		try{
			ledp = sqlMap.queryForList("ListCodigoColorCombo");
		}catch(Exception e){
			e.printStackTrace();
		}
		return ledp;
	}

}